// Copyright (c) 2021 Presto Labs Pte. Ltd.
// Author: daniel

#pragma once

#include <memory>
#include <string>

#include "coin2/exchange/base/order/order.h"
#include "coin2/exchange/lmax_digital/api_util/auth_key.h"

class LmaxdigitalNativePrivateClient : public coin2::exchange::base::order::NativePrivateClient {
 public:
  using NativeClientConfig = coin2::exchange::order::OrderConnectionConfig;

 public:
  std::shared_ptr<AsioHttpContext> SubmitOrderExecution(const OrderExecutionProto& order);
  std::shared_ptr<AsioHttpContext> SubmitRestQuery(const RestQueryProto& query);

 public:
  explicit LmaxdigitalNativePrivateClient(const NativeClientConfig& config);

  std::shared_ptr<AsioHttpContext> QueryAuth();
  std::shared_ptr<AsioHttpContext> QueryAccountBalance();
  std::shared_ptr<AsioHttpContext> QueryOpenOrders();

  void Prepare() override;
  std::shared_ptr<AsioHttpContext> PlaceOrderNorm(const OrderExecution&) override;
  std::shared_ptr<AsioHttpContext> CancelOrderNorm(const OrderExecution&) override;

 private:
  std::string token_;
  int64_t last_update_token_ts_ = 0;
};
